package testng;

import static org.testng.AssertJUnit.*;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import org.testng.ITest;
import org.testng.annotations.Factory;
import org.testng.annotations.Test;

public class FactoryTest implements ITest{

	public int size;
	public int weight;
	public String name;

	public FactoryTest(int size, int weight, String name) {
		this.size = size;
		this.weight = weight;
		this.name = name;
	}

	@Factory
	public static Object[] create() throws IOException {
		List<FactoryTest> result = new ArrayList<FactoryTest>();

		ExpectedProp ep = ExpectedProp.returnExpectedProp(Generator.gen1);
		result.add(new FactoryTest(ep.size, ep.weight, "Pesho"));

		ep = ExpectedProp.returnExpectedProp(Generator.gen3);
		result.add(new FactoryTest(ep.size, ep.weight, "Gosho"));

		ep = ExpectedProp.returnExpectedProp(Generator.grn2);
		result.add(new FactoryTest(ep.size, ep.weight, "Toni"));

		return result.toArray();
	}

	@Test
	public void testProp() {
		switch (size) {
		case 2:
			assertEquals("Not equal", 2, this.weight);
			break;
		case 6:
			assertEquals("Not equal", 5, this.weight);
			break;
		case 10:
			assertEquals("Not equal", 10, this.weight);
			break;
		default:
			fail("Not set");
		}
	}

	@Override
	public String getTestName() {
		// TODO Auto-generated method stub
		return "[" + this.name + "]";
	}
}
